const axios = require('axios');

async function aiHelper(info) {
    const url = "https://www.dmxapi.com/v1/chat/completions";

    const payload = {
        model: "gpt-4o-mini",
        messages: [
            {
                role: "system",
                content: "You are a helpful assistant."
            },
            {
                role: "user",
                content: `根据以下信息，提取其中地点、价格、配套设置等有效信息，并进行优劣分析，最后给出一个综合评价。\n${info}`,
            }
        ]
    };

    const headers = {
        'Accept': 'application/json',
        'Authorization': 'sk-zzLC6xSqw5nZNXrlvnSsy4Sdre8agQGBedGhsoEFiXil900O', // 这里放你的 DMXapi key
        'User-Agent': 'DMXAPI/1.0.0 (https://www.dmxapi.com)',
        'Content-Type': 'application/json'
    };

    try {
        const response = await axios.post(url, payload, { headers });
        return response.data.choices[0]["message"]["content"]
    } catch (error) {
        console.error(error);
    }
}

// 调用函数
module.exports = {
    aiHelper
};
